package com.ruoyi.management_controller.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.management_controller.liaison_station.StreetInfo.domain.StreetInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.management_controller.liaison_station.LiaisonStation.domain.LiaisonStation;
import com.ruoyi.management_controller.liaison_station.LiaisonStation.service.ILiaisonStationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 联络站信息Controller
 * 
 * @author ruoyi
 * @date 2024-07-09
 */
@RestController
@RequestMapping("/LiaisonStation/LiaisonStation")
public class LiaisonStationController extends BaseController
{
    @Autowired
    private ILiaisonStationService liaisonStationService;

    /**
     * 查询联络站信息列表
     */
    @PreAuthorize("@ss.hasPermi('LiaisonStation:LiaisonStation:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiaisonStation liaisonStation)
    {
        startPage();
        List<LiaisonStation> list = liaisonStationService.selectLiaisonStationList(liaisonStation);
        return getDataTable(list);
    }

    /**
     * 导出联络站信息列表
     */
    @PreAuthorize("@ss.hasPermi('LiaisonStation:LiaisonStation:export')")
    @Log(title = "联络站信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LiaisonStation liaisonStation)
    {
        List<LiaisonStation> list = liaisonStationService.selectLiaisonStationList(liaisonStation);
        ExcelUtil<LiaisonStation> util = new ExcelUtil<LiaisonStation>(LiaisonStation.class);
        util.exportExcel(response, list, "联络站信息数据");
    }

    /**
     * 获取联络站信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('LiaisonStation:LiaisonStation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(liaisonStationService.selectLiaisonStationById(id));
    }

    @GetMapping(value = "/liaisonstaioninfo")
    public List<LiaisonStation> a1(@RequestParam String id){
        List<LiaisonStation> frontdeskLiaisonStation = liaisonStationService.selectfbyStreetid(id);
        return frontdeskLiaisonStation;
    }
    /**
     * 新增联络站信息
     */
    @PreAuthorize("@ss.hasPermi('LiaisonStation:LiaisonStation:add')")
    @Log(title = "联络站信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiaisonStation liaisonStation)
    {
         liaisonStation.setId(LiaisonStation.getDefaultId());
        return toAjax(liaisonStationService.insertLiaisonStation(liaisonStation));
    }

    /**
     * 修改联络站信息
     */
    @PreAuthorize("@ss.hasPermi('LiaisonStation:LiaisonStation:edit')")
    @Log(title = "联络站信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiaisonStation liaisonStation)
    {
        //liaisonStation.setRepresentatives(String.join(liaisonStation.getRepresentatives(),","));
        return toAjax(liaisonStationService.updateLiaisonStation(liaisonStation));
    }

    /**
     * 删除联络站信息
     */
    @PreAuthorize("@ss.hasPermi('LiaisonStation:LiaisonStation:remove')")
    @Log(title = "联络站信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(liaisonStationService.deleteLiaisonStationByIds(ids));
    }



}
